Skip to content

Report properties of a readonly class as read-only - #875

Merged
Firehed merged 5 commits into
mainfrom
800/readonly-class-properties
Oct 28, 2026
Merged

Firehed merged 5 commits into
mainfrom
800/readonly-class-properties

Conversation

@Firehed

@Firehed Firehed commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Closes #800.

PHP makes every property of a readonly class read-only. Properties of built-in classes already reflected this: they come from ReflectionProperty::isReadOnly(). Properties parsed from project code only looked at their own readonly modifier, so the same PropertyInfo::isReadonly field meant different things depending on where the class came from (ADR 0006).

The parser's declaration walker now marks both body-declared and promoted properties of a readonly class as read-only. A private helper now handles the readonly-class check that the class and its properties both use.

No other route needs this fact. PHP rejects a readonly class that uses a trait with a non-readonly property or extends a non-readonly class, so every property that reaches such a class from a trait or parent is already declared readonly.

Skeleton recovery builds classes without their modifiers, so a readonly class it builds would still lose this. No file is known that reaches that path with a modified class; it predates this change and is tracked in #876.

🤖 Generated with Claude Code

Firehed and others added 4 commits October 28, 2026 08:58
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.64%. Comparing base (98fd922) to head (7b76522).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #875   +/-   ##
=========================================
  Coverage     99.64%   99.64%           
- Complexity     1966     1969    +3     
=========================================
  Files           145      145           
  Lines          4510     4513    +3     
=========================================
+ Hits           4494     4497    +3     
  Misses           16       16           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Firehed
Firehed marked this pull request as ready for review October 28, 2026 16:04
@Firehed
Firehed merged commit 1a778ad into main Oct 28, 2026
8 checks passed
@Firehed
Firehed deleted the 800/readonly-class-properties branch October 28, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Properties of a readonly class must be reported as read-only

1 participant